Skip to content

fix: replace innerHTML with DOM node construction to prevent XSS (Closes #7137) [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#8037

Open
waterWang wants to merge 1 commit into
Scottcjn:mainfrom
waterWang:fix/bcos-badge-xss
Open

fix: replace innerHTML with DOM node construction to prevent XSS (Closes #7137) [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH]#8037
waterWang wants to merge 1 commit into
Scottcjn:mainfrom
waterWang:fix/bcos-badge-xss

Conversation

@waterWang

Copy link
Copy Markdown

Security Fix

Replaces all innerHTML usages in tools/bcos-badge-generator/index.html with safe DOM node construction (createElement, textContent, appendChild, replaceChildren).

Changes

  • previewArea.innerHTML = ''previewArea.replaceChildren()
  • generateBtn.innerHTML = '<span class="spinner"></span>Generating...'createElement('span') + createTextNode
  • All preview fallback content now uses createElement and textContent instead of template strings

This prevents XSS injection through the preview fallback content path.

Closes #7137

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines labels Jul 21, 2026
@waterWang

Copy link
Copy Markdown
Author

Hi @Scottcjn, this PR fixes XSS vulnerabilities by replacing innerHTML with safe DOM node construction. Would appreciate a review when you have a moment. Thanks!

@waterWang waterWang changed the title fix: replace innerHTML with DOM node construction to prevent XSS (Closes #7137) fix: replace innerHTML with DOM node construction to prevent XSS (Closes #7137) [FaaFyfxR9WAQrL7FcAgEHJvztd8cVMxvjHRS55rw1nwH] Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static BCOS badge preview fallback templates URL with innerHTML

1 participant